#ifndef GENERATEAUDIOFILE_H
#define GENERATEAUDIOFILE_H

#include <QtCore>
class TextSpeak;
class AudioFile;

class GenerateAudioFile : public QThread
{
    Q_OBJECT
public:
    GenerateAudioFile(TextSpeak *speak, const QString &content);
    ~GenerateAudioFile();

    void init(int speed, int volume, const QString &profile, const QString &fileName);
    void release();

Q_SIGNALS:
    void doSpeakProgress(int index);

private Q_SLOTS:
    void onInit(QEventLoop *loop, int speed, int volume, const QString &profile, const QString &fileName);
    void onRelease();
    void onNext();
    void onDelayInit();
    void onSpeakBuffer(const QByteArray &data);

private:
    QString popLine();

private:
    const QString &content_;
    int index_;
    TextSpeak *speakItem_;
    QSharedPointer<AudioFile> audioFile_;
    QDateTime dateTime_;
    int stackCount_;

    QEventLoop *loop_;
    int speed_;
    int volume_;
    QString profile_;
    QString fileName_;
};

#endif // GENERATEAUDIOFILE_H
